import fetch from 'utils/fetch';
/**
 * 学校管理
 */

//根据条件分页查询学校
export function pageSchools(curPage, pageSize, realName, phone, provinceId, cityId, areaId, schoolId, periodId) {
    const data = {
        curPage,
        pageSize,
        realName,
        phone,
        provinceId,
        cityId,
        areaId,
        schoolId,
        periodId
    };
    return fetch({
        url: '/school/pageSchools',
        method: 'post',
        data
    });
}

//根据名称模糊查询学校名称
export function listSchoolByName(schoolName) {
    const data = {
        schoolName
    };
    return fetch({
        url: 'boss/school/listSchoolByName',
        method: 'post',
        data
    });
}

//查询所有学校类型
export function listSchoolPeriod() {
    const data = {

    };
    return fetch({
        url: '/school/listSchoolPeriod',
        method: 'post',
        data
    });
}

//添加学校
export function saveSchool(schoolLevel, schoolName, parentSchoolId, schoolType, periodId, year, provinceId, cityId, areaId, detail, phone, realName, subjectId) {
    const data = {
        schoolLevel,
        schoolName,
        parentSchoolId,
        schoolType,
        periodId,
        year,
        provinceId,
        cityId,
        areaId,
        detail,
        phone,
        realName,
        subjectId
    };
    return fetch({
        url: '/school/saveSchool',
        method: 'post',
        data
    });
}
//开启或关闭短信功能
export function startOrCloseMessage(status, schoolId) {
    const data = {
        status,
        schoolId
    };
    return fetch({
        url: '/boss/school/startOrCloseMessage',
        method: 'post',
        data
    });
}
//查询科目详情
export function listSubject(subjectName) {
    const data = {
        subjectName
    };
    return fetch({
        url: '/school/listSubject',
        method: 'post',
        data
    });
}

//科目详情
export function listSchoolSubject(schoolId) {
    const data = {
        schoolId
    };
    return fetch({
        url: '/school/listSchoolSubject',
        method: 'post',
        data
    });
}
//添加科目
export function updateSchoolSubject(schoolId, subjectId) {
    const data = {
        schoolId,
        subjectId
    };
    return fetch({
        url: '/school/updateSchoolSubject',
        method: 'post',
        data
    });
}

//修改学校
export function updateSchool(schoolId, schoolLevel, schoolName, parentSchoolId, provinceId, cityId, areaId, detail) {
    const data = {
        schoolId,
        schoolLevel,
        schoolName,
        parentSchoolId,
        provinceId,
        cityId,
        areaId,
        detail
    };
    return fetch({
        url: '/school/updateSchool',
        method: 'post',
        data
    });
}
//查询学校负责人
export function listSchoolOwner(schoolId) {
    const data = {
        schoolId
    };
    return fetch({
        url: '/school/listSchoolOwner',
        method: 'post',
        data
    });
}
//添加学校负责人
export function saveSchoolOwner(schoolId, realName, phone) {
    const data = {
        schoolId,
        realName,
        phone
    };
    return fetch({
        url: '/school/saveSchoolOwner',
        method: 'post',
        data
    });
}
//初始化密码
export function initPassword(schoolOwnerId) {
    const data = {
        schoolOwnerId
    };
    return fetch({
        url: '/school/initPassword',
        method: 'post',
        data
    });
}

//删除学校负责人
export function removeSchoolOwnerMap(schoolId, schoolOwnerId) {
    const data = {
        schoolId,
        schoolOwnerId
    };
    return fetch({
        url: '/school/removeSchoolOwnerMap',
        method: 'post',
        data
    });
}

//修改负责人
export function updateSchoolOwnerName(schoolOwnerId, realName, phone) {
    const data = {
        schoolOwnerId,
        realName,
        phone
    };
    return fetch({
        url: '/school/updateSchoolOwnerName',
        method: 'post',
        data
    });
}
//学校负责人禁用启用
export function enableDisable(schoolId, schoolOwnerId) {
    const data = {
        schoolId,
        schoolOwnerId
    };
    return fetch({
        url: '/school/enableDisable',
        method: 'post',
        data
    });
}

//删除学校
export function batchRemoveSchool(schoolId) {
    const data = {
        schoolId
    };
    return fetch({
        url: '/school/batchRemoveSchool ',
        method: 'post',
        data
    });
}

// 批量删除学校轮询接口
export function batchRemoveSchoolProgress(timeStamp) {
    const data = {
        timeStamp
    };
    return fetch({
        url: '/school/batchRemoveSchoolProgress ',
        method: 'post',
        data
    });
}

//查询学段
export function listPeriod() {
    const data = {

    };
    return fetch({
        url: '/school/listPeriod',
        method: 'post',
        data
    });
}


//根据学段查询年制
export function listYear(periodId) {
    const data = {
        periodId
    };
    return fetch({
        url: '/school/listYear',
        method: 'post',
        data
    });
}

//修改前查询
export function getSchool(schoolId) {
    const data = {
        schoolId
    };
    return fetch({
        url: '/school/getSchool',
        method: 'post',
        data
    });
}

//判断是否可以添加更多学校
export function validateSchoolNum() {
    return fetch({
        url: '/school/validateSchoolNum',
        method: 'post',
    });
}